package datastructure.recursion;

public class PrintFibonaci {

	static void printFibonacci(int n) {
		int a = 0;
		int b = 1;
		System.out.print(a + " "+b);	
		while(n > 1) {			
			int c = a + b;
			a = b;
			b = c;
			System.out.print( " "+c);	
			n--;
		}
	}
	
	static int fibonacci(int n) {
		if (n == 0) 
			return 0;
		else if (n == 1)
			return 1;
		else
			return fibonacci(n - 1) + fibonacci(n - 2) ;
	} // end of fibonacci

	public static void main(String[] args) {
		System.out.println("\n print ");
		printFibonacci(10);
		
		System.out.println("\n fibonacci ");		
		for (int n = 0; n <= 10; n++) {
			int x = fibonacci(n);
			System.out.print(x+" ");
		}
		
		
	}

}
